#加载包
library(tidyverse)
library(readxl)
library(writexl)
library(BiocGenerics)
library(Biobase)
#ADdata读取
list.files("./ADdata")
a1 <- read.table("./ADdata/ADdata1.txt")
a2 <- read.csv("./ADdata/ADdata2.csv")
a3 <- read_excel("./ADdata/ADdata3.xlsx")
a4 <- read.table("./ADdata/ADdata4.txt")
#ADdata合并
a1$X <- rownames(a1)
m1 <- merge(a1,a2)
m2 <- merge(m1,a3,by.x = "X",by.y = "...1")
m <- merge(m2,a4,by.x = "X",by.y = 0)
colnames(m)[1] <- "ID"
#ADdata输出
write.csv(m,file = "ad.csv")
write_xlsx(m,"ad.xlsx")
write.csv(m,file = "ad.txt")

#RNAseq读取
list.files("./RNAseq")
clin=read.csv("./RNAseq/clin_inf.csv",sep = " ")
count=read.csv("./RNAseq/count.csv",sep = " ")
exp=read.csv("./RNAseq/exp_inf.csv",sep = " ")
IDanno=read.csv("./RNAseq/ID_annoation.csv",sep = " ")
#RNAseq数据处理
meta <- merge(clin,exp)
IDanno$gene_id <- gsub("\\..*","",IDanno$gene_id)
pos <- match(count$gene_id,IDanno$gene_id)
IDanno$gene_id[pos[1:5]]
IDanno <- IDanno[pos,]
colc <- colnames(count)
colc[2:114] <- c(gsub(".$","",colc[2:114]))
colc
colnames(count) <- colc
colc<- gsub("X(...$)","PTB\\1",colc)
colc <- gsub("X","XYA",colc)
colnames(count) <- colc
rownames(count) <- count$gene_id
count <- count[,-1]
pos1 <- match(colnames(count),meta$样本名称)
meta <- meta[pos1,]
rownames(meta) <- meta$样本名称
meta <- meta[,-1]
rownames(IDanno) <- IDanno$gene_id
IDanno <- IDanno[,-1]
#创建ExpressionSet对象
eset <- ExpressionSet(assayData = as.matrix(count),
                      phenoData = new("AnnotatedDataFrame", data = meta),
                      featureData = new("AnnotatedDataFrame", data = IDanno))


